import * as moment from "moment";
import { BaseEntity } from "src/baseEntity";
import { UserSys } from "src/user/userSys.entity";
import { cryptoPassword } from "src/util/crypto";
import { Column, Entity, ManyToOne } from "typeorm";


export enum SourceType {
    ATM = "ATM",//考勤机打卡（指纹/人脸打卡）
    BEACON = "BEACON",//IBeacon
    DING_ATM = "DING_ATM", //钉钉考勤机（考勤机蓝牙打卡）
    USER = "USER",//用户打卡
    BOSS = "BOSS",// 老板改签
    APPROVE = "APPROVE",// 审批系统
    SYSTEM = "SYSTEM", //考勤系统
    AUTO_CHECK = "AUTO_CHECK", //自动打卡
}
export enum LocationResultType {
    Normal = "Normal",//范围内
    Outside = "Outside",//范围外
    NotSigned = "NotSigned"//未打卡
}
export enum TimeResultType {
    Normal = "Normal",//正常
    Early = "Early",//早退
    Late = "Late",//迟到
    SeriousLate = "SeriousLate",//严重迟到
    Absenteeism = "Absenteeism",//旷工
    NotSigned = "NotSigned",//未打卡
    Furlough = "Furlough"//休假
}
export enum CheckType {
    OnDuty = "OnDuty",//上班
    OffDuty = "OffDuty"//下班
}

@Entity("attendance")
export class Attendance extends BaseEntity {

    @ManyToOne(() => UserSys)
    user: UserSys

    @ManyToOne(() => UserSys, { nullable: true })
    target: UserSys

    @Column({ type: "enum", enum: TimeResultType })
    morning: TimeResultType

    @Column({ type: "enum", enum: TimeResultType })
    afternoon: TimeResultType

    @Column({ nullable: true })
    comment: string
}